<?php
/**
 * Created by PhpStorm.
 * User: teddy
 * Date: 16-1-7
 * Time: 下午6:47
 */


$JobID = $_GET['jobid'];



/*数据库链接*/
$mysqli = new mysqli('192.168.2.191','root','pwd','APITEST');
/*Sql语句*/
$sql = "SELECT label, COUNT(*) as count, status FROM APITEST.TestResult where label in (SELECT label FROM APITEST.TestResult where jobid = " . $JobID . " ) group by status,label order by status desc ";

/*设置UTF8*/
$mysqli->query("set character set 'utf8'");
$mysqli->query("set names 'utf8'");
/*取数据*/
$results = $mysqli->query($sql);

$resultOutput = "";

/*把数据放在Array中*/
while($row = $results->fetch_assoc())
{
    $resultOutput = $resultOutput . $row['label'] . "\t" . $row['status'] . "\t" . $row['count'] . "\n";
}

$resultOutput = rtrim($resultOutput, "\n");
echo $resultOutput;

/*释放资源*/
$results->free();

/*关闭链接*/
$mysqli->close();